package models

import "gorm.io/gorm"

type Novel struct {
	gorm.Model
	Name   string `gorm:"type:varchar(20);not null;unique" json:"name"`
	Author string `gorm:"type:varchar(10);not null" json:"author"`
	Types  string `gorm:"type:varchar(10);not null" json:"types"`
	Img    string `gorm:"type:varchar(100)" json:"img"`
}

func (n *Novel) Add() error {
	return DB.Create(&n).Error
}
func (n *Novel) GetList() (nov []*Novel, err error) {
	err = DB.Find(&nov).Error
	return nov, err
}
